import 'package:flutter/material.dart';

import '../../model/user.dart';
import '../../widgets/someCards.dart';
import '../../widgets/userSelect.dart';
import '../../helper/Helper.dart';
import '../../helper/global_config.dart';

class SKDDLAddPage extends StatefulWidget {
  @override
  SKDDLAddPageState createState() => new SKDDLAddPageState();
}

class SKDDLAddPageState extends State<SKDDLAddPage> {
  // final TextEditingController c1=new TextEditingController();
  final TextEditingController c2 = new TextEditingController();
  final String now = Helper.DateTimeNowString();
  late User sdFzr, dcFzr, gcbFzr, zppFzr;

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
  }

  upload(BuildContext context) async {}

  getDB(User u1) {
    sdFzr = u1;
  }

  getDC(User u1) {
    dcFzr = u1;
  }

  getGCB(User u1) {
    gcbFzr = u1;
  }

  getZPP(User u1) {
    zppFzr = u1;
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      //backgroundColor: Colors.white,
      appBar: AppBar(
        title: Text("调度令简述"),
      ),
      body: SKDDLAddBody(context),
    );
  }

  SKDDLAddBody(BuildContext context) => SingleChildScrollView(
        child: SKDDLAddFields(context),
      );

  SKDDLAddFields(BuildContext context) => Container(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.end,
          children: <Widget>[
            SomeCard.inCard(
                // margin: EdgeInsets.all(8.0),
                Column(
              children: <Widget>[
                ListTile(title: Text("调度令简述")),
                Divider(
                  height: 2.0,
                ),
                Container(
                    padding: EdgeInsets.only(
                        left: 16.0, right: 16.0, top: 4.0, bottom: 8.0),
                    child: TextField(
                      maxLines: null,
                      controller: c2,
                      style: TextStyle(
                          fontSize: 16.0, color: Colors.black, height: 1.5),
                    )),
              ],
            )),
            Container(
              margin: EdgeInsets.only(top: 12.0),
            ),
            SomeCard.inCard(ListTile(
                title: Text("带班领导"),
                trailing: UserSelectWidget(getDB, "部门负责人"))),
            SomeCard.inCard(ListTile(
                title: Text("电厂负责人"),
                trailing: UserSelectWidget(getDC, "电厂负责人"))),
            SomeCard.inCard(ListTile(
                title: Text("工程部负责人"),
                trailing: UserSelectWidget(getGCB, "工程部负责人"))),
            SomeCard.inCard(ListTile(
                title: Text("公司分管领导"),
                trailing: UserSelectWidget(getZPP, "公司水调分管领导"))),
            Card(
              child: (ListTile(
                title: Center(child: Text("确定发布")),
                onTap: () {
                  upload(context);
                },
              )),
              color: GlobalConfig.cardBackgroundColor,
              margin: const EdgeInsets.all(36.0),
            ),
          ],
        ),
      );
}
